<template>
  <div>
    <a-form-item :label="title">
      <depart-window-show
        :multiple-flag="false"
        :org-flag="orgFlag"
        :powerFlag="powerFlag"
        :checkedDepartKeys="departCode"
        :benbuFlag="benbuFlag"
        :placeholder-content="placeholderContent"
        @ok="departOk"
      ></depart-window-show>
    </a-form-item>
  </div>
</template>

<script>
  import DepartWindowShow from '@/components/WxDepartChoose/DepartWindowShow'

  export default {
    name: 'WxFilterDepart',
    components: { DepartWindowShow },
    props: {
      multipleFlag: {
        type: Boolean,
        default: false
      },
      placeholderContent: {
        type: String,
        default: '点击右侧按钮选择组织'
      },
      // 模式 0公司+部门 1公司 2项目
      orgFlag: {
        type: Number,
        default: -1
      },
      powerFlag: {
        type: Boolean,
        default: true
      },
      benbuFlag: {
        type: Boolean,
        default: null
      },
      checkedDepartKeys: {
        type: String,
        default: ''
      },
      required: {
        type: Boolean,
        default: false
      },
      title: {
        type: String,
        default: '部门'
      },
      value: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        checkedKeys: [],
        departCode: ''
      }
    },
    watch: {
      value: {
        handler (val) {
          this.departCode = val
        },
        immediate: true
      }
    },
    methods: {
      handleCancel () {
        this.close()
      },
      // 获取用户对应部门弹出框提交给返回的数据
      departOk (val, benbuFlag) {
        // this.$emit('ok', this.departCode)
        this.$emit('change', val)
        this.$emit('ok', benbuFlag)
        console.log('this.departCode=' + this.departCode + 'this.benbuFlag=' + benbuFlag)
      }
    },
    model: {
      prop: 'value',
      event: 'change'
    }
  }
</script>
<style scoped>
  .ant-table-tbody .ant-table-row td {
    padding-top: 10px;
    padding-bottom: 10px;
  }
</style>
